package apprentissage;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet ValiderServlet
 *
 */
 public class ValiderServlet extends javax.servlet.http.HttpServlet 
                          implements javax.servlet.Servlet {
  
  /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public ValiderServlet() {
		super();
	}

	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, 
	 *                                           HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
	                     throws ServletException, IOException {
    String resultat = "invalide";
    String valeur = request.getParameter("valeur");

    response.setContentType("text/xml");
    response.setHeader("Cache-Control", "no-cache");

    if ((valeur != null) && valeur.startsWith("X")) {
      resultat = "valide";
    }

    response.getWriter().write("<message>"+resultat+"</message>");
  }
}